function showCreateAccount()	{
	document.getElementById("hiddenForm").style.visibility = 'visible';
}
function changeIsAdmin(form)	{
	var value =form.isAdmin.options[form.isAdmin.selectedIndex].value; 
	if (value == 'yes')
	{
		document.getElementById("adPass").style.visibility = 'visible';
	}
	else
	{
		document.getElementById("adPass").style.visibility = 'hidden';
	}
}

function createUser(form){
	if (!emailValidator(form.cemail, 'not a valid email')){
		return false;
	}			
	if (form.cpassword.value == ""){
		alert("password cannot be blank");
		return false;				
	}
	if (form.rePassword.value == ""){
		alert("rePassword cannot be blank");
		return false;				
	}
	if (form.cpassword.value != form.rePassword.value){
		alert("passwords don't match");
		return false;				
	}
	if (form.isAdmin.value == 'yes'){
		if (form.adminPassword.value == ""){
			alert("admin password cannot be blank");
			return false;
		}				
	}			
	return true;
}

// validating before creating new user
function validateUser(form){
	if (emailValidator(form.email, 'not a valid email')){
		if (form.password.value != ''){
			return true;
		}
		alert("password cannot be blank");
		return false;
	}
	return false;
} 


function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}